package com.wz.dhs.vo.login;

import com.wz.dhs.po.user.SysUserEntity;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @Description 登录用户返回
 * @author xyb
 * @since 18:56 2022/7/13
 */
@Data
public class LoginUserDetail implements UserDetails {

    private SysUserEntity sysUserEntity;

    public LoginUserDetail(SysUserEntity sysUserEntity){
        this.sysUserEntity = sysUserEntity;
    }

    //权限获取
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return sysUserEntity.getPasswordEncry();
    }

    @Override
    public String getUsername() {
        return sysUserEntity.getPhone();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return sysUserEntity.getAccountStatus();
    }
}
